package com.sicau.socialpracticesystem.interceptor;

import com.sicau.socialpracticesystem.util.UserContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ttxxi
 **/
@Slf4j
public class UserContextInterceptor implements HandlerInterceptor {

    private static String TOKEN_NAME = "Authorization";


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return true;
    }


    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        //!!!!很重要，每一次结束后必须remove掉，不然会内存泄露
        UserContext.remove();
    }
}
